package cn.kgc.controller;

import cn.kgc.pojo.Pojo_hxy;
import cn.kgc.service.impl.ServiceImpl_hxy;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Controller
public class Controller_hxy {

    @Resource
    private ServiceImpl_hxy serviceImpl_hxy;

    @RequestMapping("/面试管理")
    public String mianShi() {
        return "面试管理";
    }

    @ResponseBody
    @RequestMapping("/showMianShi")
    public String showMianShi(@RequestParam String name, @RequestParam String experience,
                              @RequestParam String status, @RequestParam String positionName,
                              @RequestParam String rTime, @RequestParam Integer currentPage, @RequestParam Integer pageSize){
        PageHelper.startPage(currentPage,pageSize);
        Page<Pojo_hxy> list = serviceImpl_hxy.selAllResumes(name,positionName,experience,status,rTime);
        PageInfo<Pojo_hxy> pageInfo = new PageInfo<Pojo_hxy>(list);

        return JSON.toJSONString(pageInfo);
    }

    @ResponseBody
    @RequestMapping("/showMianShi1")
    public String showMianShi1(@RequestParam String name, @RequestParam String experience,
                              @RequestParam String status, @RequestParam String positionName,
                              @RequestParam String rTime, @RequestParam Integer currentPage, @RequestParam Integer pageSize){
        PageHelper.startPage(currentPage,pageSize);
        System.out.println(status);
        Page<Pojo_hxy> list = serviceImpl_hxy.selAllResumes1(name,positionName,experience,status,rTime);
        PageInfo<Pojo_hxy> pageInfo = new PageInfo<Pojo_hxy>(list);

        return JSON.toJSONString(pageInfo);
    }


    @RequestMapping("/录用管理")
    public String luYong() {

        return "录用管理";
    }

    @GetMapping("/面试结果登记/{rId}")
    public String mianShiDengJi(@PathVariable String rId, Model model) {

        Pojo_hxy po = serviceImpl_hxy.selResumeById(Integer.valueOf(rId));
        model.addAttribute("info",po);
        return "面试结果登记";
    }

    @ResponseBody
    @RequestMapping("/save1")
    public String mianshiDengJi(@RequestParam("interviewId")Integer interviewId,
                                @RequestParam("status")String status,
                                @RequestParam("oneInterviewer")String oneInterviewer,
                                @RequestParam("oneTime")String oneTime,
                                @RequestParam("oneOpinion")String oneOpinion,
                                @RequestParam("twoInterviewer")String twoInterviewer,
                                @RequestParam("twoTime")String twoTime,
                                @RequestParam("twoOpinion")String twoOpinion,
                                @RequestParam("threeInterviewer")String threeInterviewer,
                                @RequestParam("threeTime")String threeTime,
                                @RequestParam("threeOpinion")String threeOpinion){
        int a = serviceImpl_hxy.updView(interviewId,status,oneInterviewer,oneTime,oneOpinion,twoInterviewer,twoTime, twoOpinion,
                threeInterviewer,threeTime, threeOpinion, "","");

        return JSON.toJSONString(a);
    }

    @ResponseBody
    @RequestMapping("/save11")
    public String mianshiDengJi1(@RequestParam("interviewId")Integer interviewId,
                                 @RequestParam("status")String status,
                                 @RequestParam("oneInterviewer")String oneInterviewer,
                                 @RequestParam("oneTime")String oneTime,
                                 @RequestParam("oneOpinion")String oneOpinion){
        int a = serviceImpl_hxy.updView(interviewId,status,oneInterviewer,oneTime,oneOpinion,"","", "",
                "","", "", "","");

        return JSON.toJSONString(a);
    }
    //
    @ResponseBody
    @RequestMapping("/save12")
    public String mianshiDengJi2(@RequestParam("interviewId")Integer interviewId,
                                 @RequestParam("status")String status,
                                 @RequestParam("twoInterviewer")String twoInterviewer,
                                 @RequestParam("twoTime")String twoTime,
                                 @RequestParam("twoOpinion")String twoOpinion){
        int a = serviceImpl_hxy.updView(interviewId,status,"","", "",twoInterviewer,twoTime,twoOpinion,
                "","", "", "","");

        return JSON.toJSONString(a);
    }

    @ResponseBody
    @RequestMapping("/save13")
    public String mianshiDengJi3(@RequestParam("interviewId")Integer interviewId,
                                 @RequestParam("status")String status,
                                 @RequestParam("threeInterviewer")String threeInterviewer,
                                 @RequestParam("threeTime")String threeTime,
                                 @RequestParam("threeOpinion")String threeOpinion){
        int a = serviceImpl_hxy.updView(interviewId,status,"","", "",
                "","", "",threeInterviewer,threeTime,threeOpinion, "","");

        return JSON.toJSONString(a);
    }



    @RequestMapping("/录用结果登记/{rId}")
    public String luYongDengJi(@PathVariable String rId, Model model) {

        Pojo_hxy po = serviceImpl_hxy.selResumeById(Integer.valueOf(rId));
        model.addAttribute("info",po);
        return "录用结果登记";
    }


    @ResponseBody
    @RequestMapping("/save2")
    public String luyongDengJi(@RequestParam("interviewId")Integer interviewId,
                                @RequestParam("status")String status,
                                @RequestParam("oneInterviewer")String oneInterviewer,
                                @RequestParam("oneTime")String oneTime,
                                @RequestParam("oneOpinion")String oneOpinion,
                                @RequestParam("twoInterviewer")String twoInterviewer,
                                @RequestParam("twoTime")String twoTime,
                                @RequestParam("twoOpinion")String twoOpinion,
                                @RequestParam("threeInterviewer")String threeInterviewer,
                                @RequestParam("threeTime")String threeTime,
                                @RequestParam("threeOpinion")String threeOpinion,
                                @RequestParam("endTime")String endTime,
                                @RequestParam("endOpinion")String endOpinion){
        int a = serviceImpl_hxy.updView(interviewId,status,oneInterviewer,oneTime,oneOpinion,twoInterviewer,twoTime, twoOpinion,
                threeInterviewer,threeTime, threeOpinion, endTime,endOpinion);

        return JSON.toJSONString(a);
    }

    @ResponseBody
    @RequestMapping("/save21")
    public String luyongDengJi1(@RequestParam("interviewId")Integer interviewId,
                               @RequestParam("status")String status,
                               @RequestParam("endTime")String endTime,
                               @RequestParam("endOpinion")String endOpinion){
        int a = serviceImpl_hxy.updView(interviewId,status,"","","","","", "",
                "","", "", endTime,endOpinion);

        return JSON.toJSONString(a);
    }

    @ResponseBody
    @RequestMapping("/save22")
    public String luyongDengJi2(@RequestParam("interviewId")Integer interviewId,
                                @RequestParam("status")String status){
        int a = serviceImpl_hxy.updView1(interviewId,status,"","","","","", "",
                "","", "", "","");

        return JSON.toJSONString(a);
    }

}
